package research.ui.views;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

import research.core.Activator;
import research.entity.Entity;

class ViewLabelProvider extends LabelProvider {

	public String getText(Object obj) {
		return obj.toString();
	}

	public Image getImage(Object obj) {

		Image img = null;
		if (obj instanceof Entity) {
			img = Activator.getImageDescriptor(
					((Entity) obj).getType().getIconUri()).createImage();
		}

		return img == null ? PlatformUI.getWorkbench().getSharedImages()
				.getImage(ISharedImages.IMG_OBJ_ELEMENT) : img;
	}
}